<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, minimal-ui">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval' ">
    <title>找师傅APP插件Demo</title>
    <link rel="stylesheet" href="style.css" media="screen" title="no title" charset="utf-8">
  </head>
  <body>
    <header class="header">
      <h1><a class="btn-back" href="./index.html">首页</a>支付</h1>
    </headerr
    <form>
      <ul>
        <li>
          <label for="money">支付金额:</label>
          <input type="text" name="money" value="0.01" id="money-input"/>
        </li>
        <br/>
        <li>
          <a class="btn wechatpay" >微信支付</a>
          <a class="btn alipay" >支付宝支付</a>
        </li>
      </ul>
    </form>
    <script type="text/javascript" src="../cordova.js"></script>
    <script type="text/javascript">
      document.querySelector('.alipay').addEventListener('click', function() {
        var orderInfo = {
          subject: '换个名字骗钱',
          body: '这是一个测试，用的是真金白银，最好用一分钱来测试',
          price: document.querySelector('#money-input').value,
          tradeNo: 'U10505-150812-3875',
          timeout: '90m',
          seller: '3234811092@qq.com'
        }
        var onSuccess = function(data) {
          alert('success: ' + data)
        }
        var onError = function(error) {
          alert('error: ' + error)
        }
        if (document.querySelector('#money-input').value > 0) {
          cordova.exec(onSuccess, onError, "Alipay", "pay", [orderInfo]);
        } else {
          alert('请输入金额')
        }

        // navigator.alipay.pay(orderInfo, onSuccess, onError)
      })

    </script>
  </body>
</html>
